package com.ning.farm_income_back.controller;

import com.ning.farm_income_back.domain.Users;
import com.ning.farm_income_back.service.CostsService;
import com.ning.farm_income_back.service.ProfitService;
import com.ning.farm_income_back.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/profit")
public class ProfitController {

    @Autowired
    private ProfitService profitService;


    //查询总利润
    @GetMapping("/getTotalProfit")
    public ResultVo<String> getTotalProfit() {
        String total = profitService.getTotalProfit() ;
        return ResultVo.success("查询成功",total);
    }

    //查询当前用户获得的利润
    @GetMapping("/getOneProfit/{username}")
    public ResultVo<String> getOneProfit(@PathVariable String username) {
        String profit = profitService.getOneProfit(username) ;
        return ResultVo.success("查询成功",profit);
    }

    @PutMapping("updateProfit")
    public ResultVo<String> updateProfit() {
        profitService.updateProfit();
        return ResultVo.success("更新成功");
    }


}
